Security News
NVD Backlog Tops 20,000 CVEs Awaiting Analysis as NIST Prepares System Updates
NVD’s backlog surpasses 20,000 CVEs as analysis slows and NIST announces new system updates to address ongoing delays.
Return an object for a glob of files. Pass a `rename` function for the keys, or a `parse` function for the content, allowing it to be used for readable or require-able files.
Return an object for a glob of files. Pass a
rename
function for the keys, or aparse
function for the content, allowing it to be used for readable or require-able files.
npm i map-files --save-dev
npm test
var mapFiles = require('map-files');
console.log(mapFiles('lib/*.txt'));
Returns an object that looks something like:
{ 'fixtures/a.txt': { name: 'a.txt' , contents: 'This is file a.txt.' },
'fixtures/b.txt': { name: 'b.txt' , contents: 'This is file b.txt.' },
'fixtures/c.txt': { name: 'c.txt' , contents: 'This is file c.txt.' } }
patterns
{String}: Glob patterns to pass to globbyopts
{Object}: Options for globby, or pass a custom parse
or rename
.returns
: {Object}Return an object for all files matching the given patterns
and options
. The full filepath of the file is used as the key.
Pass a rename function to be used as the key of each file object:
var files = mapFiles('lib/*.txt', {
rename: function (filepath) {
return path.basename(filepath);
}
});
console.log(files);
Returns something like:
{ 'fixtures/a.txt': { name: 'a' , contents: 'This is file a.txt.' },
'fixtures/b.txt': { name: 'b' , contents: 'This is file b.txt.' },
'fixtures/c.txt': { name: 'c' , contents: 'This is file c.txt.' } }
Pass a parsing function to change the object returned for each file. The
default function reads files and returns a string. This example shows how
you might instead require
each file.
var files = mapFiles('lib/*.txt', {
parse: function (filepath) {
return {
path: filepath,
fn: require(path.resolve(filepath))
}
}
});
console.log(files);
Returns something like:
{ 'fixtures/a.js': { path: 'fixtures/a.js' , fn: { foo: [Function: foo] } },
'fixtures/b.js': { path: 'fixtures/b.js' , fn: { bar: [Function: bar] } },
'fixtures/c.js': { path: 'fixtures/c.js' , fn: { baz: [Function: baz] } } }
Jon Schlinkert
Copyright (c) 2014 Jon Schlinkert, contributors.
Released under the MIT license
This file was generated by verb-cli on September 20, 2014.
FAQs
Return an object for a glob of files. Pass a `rename` function for the keys, or a `parse` function for the content, allowing it to be used for readable or require-able files.
The npm package map-files receives a total of 2,791 weekly downloads. As such, map-files popularity was classified as popular.
We found that map-files demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
NVD’s backlog surpasses 20,000 CVEs as analysis slows and NIST announces new system updates to address ongoing delays.
Security News
Research
A malicious npm package disguised as a WhatsApp client is exploiting authentication flows with a remote kill switch to exfiltrate data and destroy files.
Security News
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.